<?php
class Helper_Item {
	private static $instance;
	
	public static function newInstance() {
		if (! self::$instance instanceof self) {
			self::$instance = new self ();
		}
		return self::$instance;
	}
	
	public function __construct() {
	
	}
	
	function validate_name($name) {
		if ($name == '' || strlen ( $name ) < 5) {
			return false;
		}
		return true;
	}
	function sanitize_name($name) {
		$name = ereg_replace ( "[^A-Za-z0-9-]", "-", $name );
		while ( strpos ( $name, '--' ) ) {
			$name = str_replace ( '--', '-', $name );
		}
	
			$name = str_replace ( '-', ' ', $name );
	
		return $name;
	}
	
	function validate_description($desc){
		if($desc==''){
			return false;
		}
		if(str_word_count($desc)<10){
			return false;
		}
		return true;
	}
	
	function sanitize_description($desc){
		// Write function to sanitize the description later
		return $desc;
	}
	
	function validate_price($price){
		if($price==''){
			return false;
		}
		$t=(floatval($price));
		if(!$t>0){
			return false;
		}
		return true;
	}
	
	function sanitize_price($price){
		return floatval($price);
	}
}